<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>   
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>添加</title>
<link rel="stylesheet" href="${ctx }/resources/layui/css/layui.css" media="all" />
<link rel="stylesheet" href="${ctx }/resources/css/public.css" media="all" />
<link rel="stylesheet" href="${ctx }/resources/zTree/css/metroStyle/metroStyle.css" type="text/css">
<link rel="stylesheet" type="text/css" href="${ctx }/resources/plugin/css/index.css">
</head>
<body class="childrenBody">
	<form class="layui-form" action="#" id="frm" method="post" lay-filter="frm">
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label">选择供应商</label>
				<div class="layui-input-inline">
					<select name="providerid" id="providerid" lay-filter="providerid">
						<c:forEach var="sn" items="${providers }">
							<option value="${sn.id }">${sn.providername }</option>
						</c:forEach>
					</select>
				</div>
			</div>
			<div class="layui-inline">
				<label class="layui-form-label">商品名称</label>
				<div class="layui-input-inline">
					<select name="goodsid" id="goodsid" lay-filter="goodsid">
							<option value=""></option>
					</select>
				</div>
			</div>
		</div>
		
	<div class="layui-form-item">
		<div class="layui-inline">
			<label class="layui-form-label">退货数量</label>
			<div class="layui-input-inline">
				<input type="hidden" name="operateperson" value="${user.name }">
				<input type="text" name="number" id="number" lay-verify="required"
					autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-inline">
			<label class="layui-form-label">退货时间</label>
			<div class="layui-input-inline">
				<input type="text" name="outputtime" id="outputtime"  autocomplete="off" class="layui-input">
			</div>
		</div>
	</div>
	
	<div class="layui-inline">
		<label class="layui-form-label">支持类型</label>
		<div class="layui-input-inline">
			<input type="radio" name="paytype" value="微信" title="微信" >
			<input type="radio" name="paytype" value="支付宝" title="支付宝" checked=""> 
			<input type="radio" name="paytype" value="现金" title="现金"> 
		</div>
	</div>
	
	<div class="layui-form-item layui-form-text">
		<label class="layui-form-label">退货备注</label>
		<div class="layui-input-block">
			<textarea placeholder="请输入内容" name="remark" class="layui-textarea"></textarea>
		</div>
	</div>
		
		<div class="layui-form-item">
			<div class="layui-input-block" style="text-align: center;">
				<!--lay-submit标记当按钮是一个提交按钮   -->
				<a href="javascript:void(0)" class="layui-btn" lay-submit=""  lay-filter="outportSubmit">提交</a>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>
	</form>
</body>
<script type="text/javascript" src="${ctx }/resources/layui/layui.js"></script>
<script type="text/javascript" src="${ctx }/resources/zTree/js/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="${ctx }/resources/zTree/js/jquery.ztree.core.js"></script>
<script type="text/javascript" src="${ctx }/resources/plugin/js/selectTree.js"></script>
<script type="text/javascript">
layui.use([ 'form','jquery','layer','laydate' ], function() {
	var form=layui.form;//得到form对象
	var $=layui.jquery;
	var laydate=layui.laydate;
	var layer = parent.layer === undefined ? layui.layer : parent.layer;
	
	//时间选择器的绑定
	laydate.render({
		elem:'#outputtime'
	});
	//添加提交事件
	form.on("submit(outportSubmit)",function(data){
		var params=$("#frm").serialize();
		$.post("${ctx}/outport/addOutport.action?"+params,function(obj){
			layer.msg(obj.msg);
			parent.tableIns.reload();//刷新表格
			//关闭窗口
			var index=layer.getFrameIndex(window.name);
			layer.close(index);
		}) 
	});
	
	//select的chage监听事件使用
	form.on('select(providerid)', function(obj){   //providerid是 lay-filter属性值
		var providerid=obj.value;
		$.post("${ctx}/goods/loadGoodsByProviderId.action",{providerid:providerid},function(data){
		var html="";
		//alert(providerid);
		for (var i = 0; i < data.length; i++) {
			html+="<option value="+data[i].id+">"+data[i].goodsname+"</option>"
		}
		$("#goodsid").html(html);
			form.render("select");
		})
	})
	
});	
	
</script>
</html>